<?php
    /**
     * 雅思APP接口基础类
     */
	namespace app\libs;
    use app\modules\weixin\models\UserToken;
    use yii;
    use yii\web\Controller;

    header("Access-Control-Allow-Origin:*");
    header('Access-Control-Allow-Headers: X-Requested-With,Token');
    header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
    header("Access-Control-Allow-Credentials: true");
	class WeixinControl extends Controller {
	    public $uid;
		public function init() {
            $token = isset($_SERVER['HTTP_TOKEN']) && !empty($_SERVER['HTTP_TOKEN'])?$_SERVER['HTTP_TOKEN']:false;
            $uid = 0;
            if($token){
                $time = time()-604800;
                $user = UserToken::find()->where("token='$token' AND createTime>$time")->one();
                if($user){
                    $uid = $user->uid;
                }
            }
            $this->uid = $uid;
		}
	}
?>